<?php
/*
 * 来路分析相关
 * copyright:living10
 */
 class SystemFunctions extends CI_Controller{
	public function __construct(){
		parent::__construct();
		$this->load->model('SystemFunctions_model');
		$this->load->model('tongji_model');
		$this->load->library('Tools');
	}

	//修改关键词
	public function showKeyWord()
	{
		$header['title'] = '添加修改关键词';
		$header['location1'] = '系统功能';
		$header['location2'] = '添加修改关键词';
		$data= $this->SystemFunctions_model->showKeyWord();
 		$this->load->view('main/header',$header);
 		$this->load->view('main/SystemFunctions/modiftykeyword',$data);
 		$this->load->view('main/footer');
	}

	//保存关键词
	public function saveKeyWord()
	{
		$this->SystemFunctions_model->saveKeyWord();
//		redirect($this->config->item("site_url")."SystemFunctions/showKeyWord");
		$this->tools->showMessage("保存成功！",'back');
	}

	//ip黑白名单
	public function ipblacklist()
	{
		$header['title'] = 'IP黑白名单设置';
		$header['location1'] = '系统功能';
		$header['location2'] = 'IP黑白名单设置';

		$data['data'] = $this->SystemFunctions_model->ipblacklist();
		$this->load->view('main/header',$header);
 		$this->load->view('main/SystemFunctions/ipblacklist',$data);
 		$this->load->view('main/footer');
	}
	//保存ip黑名单
	public function saveipblack()
	{
		$data['data'] = $this->SystemFunctions_model->save_ipblack();
		$this->tools->showMessage("保存成功！",$this->config->item("site_url")."SystemFunctions/ipblacklist?".time());
	}

	//意向度设置
	public function intent()
	{
		$header['title'] = '意向度设置';
		$header['location1'] = '系统功能';
		$header['location2'] = '意向度设置';
		$data['setting']= $this->SystemFunctions_model->get_MaliciousClicksSetting();
		$this->load->view('main/header',$header);
 		$this->load->view('main/SystemFunctions/intent',$data);
 		$this->load->view('main/footer');
	}
	//更新意向度设置
	public function upd_intent(){
		$flag = $this->SystemFunctions_model->upd_intent();
		$alert_str = "保存成功！";
		if($flag!=1)
		{
			$alert_str = "保存失败！";
		}
		$this->tools->showMessage($alert_str,'back');
	}

	//pv流向
	public function showPvExport()
	{

		$header['title'] = 'PV流向';
		$header['location1'] = '系统功能';
		$header['location2'] = 'PV流向';
		$data['data'] = array();
		$this->load->view('main/header',$header);
 		$this->load->view('main/SystemFunctions/pvExport',$data);
 		$this->load->view('main/footer');
	}

	//自定义恶意点击
	public function MaliciousClicksSetting()
	{
		$header['title'] = '自定义恶意点击';
		$header['location1'] = '系统功能';
		$header['location2'] = '自定义恶意点击';
		$data['setting']= $this->SystemFunctions_model->get_MaliciousClicksSetting();
		$this->tongji_model->getWebSiteInfo();
		$this->load->view('main/header',$header);

 		$this->load->view('main/SystemFunctions/MaliciousClicksSetting',$data);
 		$this->load->view('main/footer');
	}
	//更新自定义恶意点击
	public function edit_MaliciousClicksSetting()
	{
		$flag = $this->SystemFunctions_model->upd_MaliciousClicksSetting();
		$alert_str = "保存成功！";
		if($flag!=1)
		{
			$alert_str = "保存失败！";
		}
		$this->tools->showMessage($alert_str,'back');

	}
	//删除黑名单设置
	public function del_ipblack(){
		$flag = $this->SystemFunctions_model->del_ipblack();
		$alert_str = "操作成功！";
		if($flag!=1)
		{
			$alert_str = "操作失败！";
		}
		$this->tools->showMessage($alert_str,$this->config->item("site_url")."SystemFunctions/ipblacklist?".time());
	}
	//屏蔽恶意访客
	public function vidguanbi()
	{
		if($this->input->post('lanjie_vid'))
		{
			$this->SystemFunctions_model->editVid(intval($this->input->post('lanjie_vid')),intval($this->input->post('state')));
			exit(1);
		}
		$header['title'] = '屏蔽恶意访客';
		$header['location1'] = '系统功能';
		$header['location2'] = '屏蔽恶意访客';
		$search_day = intval($this->input->get("search_day")?$this->input->get("search_day"):0);
		$search_sdate = htmlspecialchars($this->input->post("search_sdate")?$this->input->post("search_sdate"):date('Y-m-d',strtotime("-".$search_day." day")));
		$search_edate = htmlspecialchars($this->input->post("search_edate")?$this->input->post("search_edate"):date('Y-m-d'));
		$data= $this->SystemFunctions_model->showVid($search_sdate,$search_edate);

		$data['search_sdate'] = $search_sdate;
		$data['search_edate'] = $search_edate;
		$data['search_day'] = $search_day;
 		$this->load->view('main/header',$header);
 		$this->load->view('main/SystemFunctions/showVid',$data);
 		$this->load->view('main/footer');

	}
 }
?>
